package com.leetcode.partition1;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/6 16:48
 */
public class LCP04覆盖 {

    private static final int N = 10, M = 10;
    private static final int[][] dirs = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
    private static boolean[][] graph = new boolean[N][M], st = new boolean[N][M];
    private static int[][][] match = new int[N][M][2];

    private static int n = 0, m = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]), t = Integer.parseInt(ss[2]);
        int[][] broken = new int[t][2];
        for (int i = 0; i < t; i++) {
            ss = reader.readLine().split(" ");
            int x = Integer.parseInt(ss[0]), y = Integer.parseInt(ss[1]);
            broken[i] = new int[]{x, y};
        }
        writer.write(domino(n, m, broken) + "\n");
        writer.flush();
    }

    public static int domino(int _n, int _m, int[][] broken) {
        n = _n;
        m = _m;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                match[i][j][0] = match[i][j][1] = -1;
            }
        }
        for (int[] pair : broken) graph[pair[0]][pair[1]] = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((i + j) % 2 == 1 && !graph[i][j]) {
                    for (int k = 0; k < N; k++) Arrays.fill(st[k], false);
                    if (dfs(i, j)) ans++;
                }
            }
        }
        return ans;
    }

    private static boolean dfs(int x, int y) {
        for (int[] dir : dirs) {
            int nx = x + dir[0], ny = y + dir[1];
            if (nx < 0 || nx >= n || ny < 0 || ny >= m || graph[nx][ny] || st[nx][ny]) continue;
            st[nx][ny] = true;
            int[] pair = match[nx][ny];
            if (pair[0] == -1 || dfs(pair[0], pair[1])) {
                match[nx][ny] = new int[]{x, y};
                return true;
            }
        }
        return false;
    }
}
